﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.Data.DbUtils.DataMapping;
using PMS.Data.Entities.ScheduleTasks;

namespace PMS.Data.EntityMap.ScheduleTasks
{
    /// <summary>
    /// Represents a SystemScheduleTask mapping configuration
    /// </summary>
    public partial class SystemScheduleTaskMap : PMSEntityTypeConfiguration<SystemScheduleTask>
    {
        #region Methods

        /// <summary>
        /// Configures the entity
        /// </summary>
        /// <param name="builder">The builder to be used to configure the entity</param>
        public override void Configure(EntityTypeBuilder<SystemScheduleTask> builder)
        {
            builder.ToTable("sys_scheduletask");
            builder.HasKey(task => task.Id);

            builder.Property(task => task.TaskName).HasMaxLength(200).IsRequired();
            builder.Property(task => task.GroupName).HasMaxLength(200).IsRequired();
            builder.Property(task => task.Comment).HasMaxLength(1024);
            builder.Property(task => task.CronExpression).HasMaxLength(200).IsRequired();
            builder.Property(task => task.Type).HasMaxLength(500).IsRequired();
            builder.Property(task => task.Status).IsRequired();

            builder.Ignore(task => task.IsActive);
            builder.Ignore(task => task.CreatedOnTimeUtc);
            builder.Ignore(task => task.UpdatedOnTimeUtc);
            base.Configure(builder);
        }

        #endregion
    }
}
